#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:3.1 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:3.1 AS build
WORKDIR /src
COPY ["Md.Demo.API/Md.Demo.API.csproj", "Md.Demo.API/"]
COPY ["Md.Demo.Protos/Md.Demo.Protos.csproj", "Md.Demo.Protos/"]
COPY ["Md.Demo.Rpc/Md.Demo.Rpc.csproj", "Md.Demo.Rpc/"]
RUN dotnet restore "Md.Demo.API/Md.Demo.API.csproj"
COPY . .
WORKDIR "/src/Md.Demo.API"
RUN dotnet build "Md.Demo.API.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "Md.Demo.API.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "Md.Demo.API.dll"]